package com.neu.service;

import com.github.pagehelper.PageHelper;
import com.neu.dao.ShoppingSearchHistoryMapper;
import com.neu.domain.ShoppingIssueExample;
import com.neu.domain.ShoppingSearchHistory;
import com.neu.domain.ShoppingSearchHistoryExample;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class ShoppingSearchHistoryService {
	@Autowired
	private ShoppingSearchHistoryMapper shoppingSearchHistoryMapper;
	public List<ShoppingSearchHistory> querySelective(String from,String keyword,Integer page, Integer limit, String sort, String order){
		ShoppingSearchHistoryExample example=new ShoppingSearchHistoryExample();
		ShoppingSearchHistoryExample.Criteria criteria = example.createCriteria();

	       if (!StringUtils.isEmpty(from)) {
	           criteria.andFromLike("%" + from + "%");
	       }
	       if (!StringUtils.isEmpty(keyword)) {
	           criteria.andKeywordLike("%" + keyword + "%");
	       }
	       criteria.andDeletedEqualTo(false);

	       if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
	           example.setOrderByClause(sort + " " + order);
	       }
	       PageHelper.startPage(page, limit);
	       return shoppingSearchHistoryMapper.selectByExample(example);
	}

}
